Node.js debugging
Node.js debugging in VS Code
debugging Node.js port 9229
Debugging - Getting Started | Node.js
前提
nodejs --inspect で、
localhost:9229/UUID を linstenする状態で app? が立ち上がる
inspector clientは、ws://127.0.0.1:9229/UUID を見に行けばよい。
あと、SIGUSR1 signalを受けると、debugger messageをlistenし始める
--debugは、legacyなdebugging?
debuggerを 0.0.0.0にboundすることは、デフォルトでは許容されてない。
same domainポリシーなどもある。
Puppeteer前提で考えたい場合
関心のあるページ(url)で、await page.evaluate( () => {debugger;});する
Clients
node inspect
node inspect hello0.js
chrome devtools
VSCode Debugging
.vscode/launch.json
jetbrainのもの、Gitpod
chrome-remote-interface
options:
--inspect-brk で、user code 開始前にbreakできる
$ node --inspect --debug-brk foo.js
chrome 上でdebugできる chrome://inspectから入れる。targetが表示される。
consoleも使えるので、これでまずはOK?
async?はどうする?
機能
Enable inspetor 
Security implicationns
Inspector clients
node-inspect
chrome devtools
chrome remote interface???
cyrus-and/chrome-remote-interface: Chrome Debugging Protocol interface for Node.js
VSCode
Commandline options
Enabling remote debugging senarios
sshによるport forwardingをする。localの9221をremoteの9229をにつなぐ
ssh -L 9221:localhost:9229 user@remote.example.com
で、chromeなどで attachする